package com.example.metodo_post;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;

public class editar_cliente extends Activity {
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.editar_cliente);
        String server_url = getIntent().getStringExtra("server_url");
        String nombre = getIntent().getStringExtra("nombre");
        
		ListView lista = (ListView) findViewById(R.id.listview);
		web_page url = new web_page();
		
		List<String> listaArray = new ArrayList<String>();
		listaArray.add("Datos del Usuario: ");
		listaArray.addAll(url.datos_cliente(server_url, nombre));
		
		ListView listview = (ListView) findViewById(R.id.listview);
		listview.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1 , listaArray));
		
		//ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, listaArray);
		//List<Map<String, String>> data = new ArrayList<Map<String, String>>();
		// create the grid item mapping
        /*String[] from = new String[] {"nombre", "apellido","cedula"};
        int[] to = new int[] {R.id.item2, R.id.item3};
 
        // prepare the list of all records
        List<HashMap<String, String>> fillMaps = new ArrayList<HashMap<String, String>>();
        Iterator<String> ciclo = listaArray.iterator();
        while(ciclo.hasNext()){
        //for(int i = 0; i < 10; i++){
            HashMap<String, String> map = new HashMap<String, String>();
            //map.put("Cedula: ", "col_1_item_");
            map.put("nombre", ciclo.next());
            map.put("apellido", ciclo.next());
            fillMaps.add(map);
        //}
        }
		
         // fill in the grid_item layout
            SimpleAdapter adapter1 = new SimpleAdapter(this, fillMaps, R.layout.grid_item, from, to);  
            lista.setAdapter(adapter1);
		
		/*SimpleAdapter adapters = new SimpleAdapter(this, data, android.R.layout.simple_list_item_2, new String[] {"title", "date"},
                new int[] {android.R.id.text1, android.R.id.text2});*/ 
	}

}	
